home *** CD-ROM | disk | FTP | other *** search
- /*
- * scan_img.c
- *
- * Practical Algorithms for Image Analysis
- *
- * Copyright (c) 1997, 1998, 1999 MLMSoftwareGroup, LLC
- */
-
- /*
- * SCAN_IMG.C
- *
- * routine to extract point coordinates from input image array
- *
- */
- #include <stdlib.h>
- #include <stdio.h>
- #include "spp.h"
-
- #define F_TO_INT(x) ( ((x)-(int)(x)<0.5) ? (int)(x) : (int)(x)+1 )
-
- #undef DEBUG
-
-
- /*globals */
- extern char **image; /* input/output image */
- extern int left_x, right_x;
- extern int i, j;
-
- extern int NMAX;
-
-
-
-
- /*
- * x_pp()
- * DESCRIPTION:
- * scan binary image end extract point object coordinates
- * note: match_index should be identical to the gray value emplyed in
- * routine mark_centroid()/ah_aoi.c
- * ARGUMENTS:
- * Cxy: Pix structure to be filled in (Pix *)
- * n: number of points found (long *)
- * left_x: leftmost x value (int)
- * imin: row min (int)
- * right_x: rightmost x value (int)
- * imax: row max (int)
- * RETURN VALUE:
- * 1 if NMAX is not exceeded
- * 0 otherwise
- */
-
- int
- x_pp (Cxy, n, left_x, imin, right_x, imax)
- struct Pix *Cxy;
- long *n;
- int left_x, imin, right_x, imax;
- {
- int ir, jc;
- unsigned char cur_index, match_index;
-
-
- match_index = 255;
- printf (" -- match index: %d\n", match_index);
- printf ("...row:");
- for (ir = imin; ir < imax; ir++) {
- if (ir % 50 == 0)
- printf ("...%3d", ir);
-
- for (jc = left_x; jc < right_x; jc++) {
- if ((cur_index = image[ir][jc]) == match_index) {
- if (*n < NMAX) {
- *n += 1;
- (Cxy + *n - 1)->x = (int) (jc);
- (Cxy + *n - 1)->y = (int) ir;
- #ifdef DEBUG
- printf ("\n...jc:%d, x:%d, ir:%d, y:%d, n:%ld\n",
- jc, (Cxy + *n - 1)->x, ir, (Cxy + *n - 1)->y, *n - 1);
- #endif
- }
- else
- return (0);
- }
- }
- }
- return (1);
- }
-